package br.com.sipsoft.svola.factory;

import javax.persistence.NoResultException;
import javax.persistence.Query;

import org.springframework.stereotype.Repository;

import br.com.sipsoft.svola.entidades.ManadTipoRegistro;

@Repository
public class ManadTipoRegistroFactory extends BaseFactory {

	public ManadTipoRegistro loadManadTipoRegistro(String tipoRegistro, String versao ){
		StringBuilder hql = new StringBuilder();
		
		hql.append(" select manadTipoRegistro ");
		hql.append(" from ManadTipoRegistro manadTipoRegistro ");				
		hql.append(" where manadTipoRegistro.tipoRegistroManad = :tipoRegistro ");
		hql.append(" and manadTipoRegistro.versao = :versao ");
		Query q = hibernateUtils.getCurrentEntityManager().createQuery(hql.toString());
		q.setParameter("tipoRegistro", tipoRegistro);
		q.setParameter("versao", versao);
		
		try {
			return (ManadTipoRegistro) q.getSingleResult();
		} catch (NoResultException  e) {
			return null;
		}
	}
}
